<%@ page import="id.co.gomobile.assessment.Test" %>
<%@ page import="id.co.gomobile.assessment.Preference"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title>Create Test</title>
    </head>
    <body>
    <g:render template="/shared/navigation" />
    
    <div id="body">
    
    <h1>Create Test</h1>

    <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
    </g:if>

    <g:hasErrors bean="${testInstance}">
    <div class="errors">
        <g:renderErrors bean="${testInstance}" as="list" />
    </div>
    <br/>
    </g:hasErrors>

    <g:form action="save" method="post" >
    <div class="form">

    <fieldset>        
        <h3>General Information</h3>
        
        <br/>
    
        <label for="name" class="required ${hasErrors(bean: testInstance, field: 'name', 'errors')}">Name :</label>
        <div class="value">
            <g:textField name="name" maxlength="64" value="${testInstance?.name}" />
        </div>
                
        <br/>

        <label for="description" class="${hasErrors(bean: testInstance, field: 'description', 'errors')}">Description :</label>
        <div class="value">
            <g:textArea name="description" value="${testInstance?.description}" />
        </div>

        <br/>
        
        <h3>Preference</h3>
        
        <br/>

        <label for="preference.timeout" class="required ${hasErrors(bean: testInstance, field: 'preference.timeout', 'errors')}">Timeout :</label>
        <div class="value">
            <g:textField name="preference.timeout" maxlength="5" value="${testInstance?.preference?.timeout}" />
        </div>
        <div class="notes">Set time in minutes, how long the user should finish the test.</div>

        <br/>

        <label for="preference.maxQuestions" class="required ${hasErrors(bean: testInstance, field: 'preference.maxQuestions', 'errors')}">Max. Questions :</label>
        <div class="value">
            <g:textField name="preference.maxQuestions" maxlength="5" value="${testInstance?.preference?.maxQuestions}" />
        </div>
        <div class="notes">Number of questions presented to user.</div>

        <br/>

        <label for="preference.maxQuestionsPerPage" class="required ${hasErrors(bean: testInstance, field: 'preference.maxQuestionsPerPage', 'errors')}">Max. Questions / Page :</label>
        <div class="value">
            <g:textField name="preference.maxQuestionsPerPage" maxlength="5" value="${testInstance?.preference?.maxQuestionsPerPage}" />
        </div>
        <div class="notes">Number of questions per page.</div>

        <br/>

        <label for="preference.forceSubmitOnTimeout" class="required ${hasErrors(bean: testInstance, field: 'preference.forceSubmitOnTimeout', 'errors')}">Force Submit On Timeout :</label>
        <div class="value">
            <g:checkBox name="preference?.forceSubmitOnTimeout" value="${testInstance?.preference?.forceSubmitOnTimeout}" />
        </div>
        <div class="notes">Force system to submit test on timeout.</div>

        <br/>
        <br/>

        <div class="buttons">
            <span class="button"><g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
        </div>
    </fieldset>

    </div>
    </g:form>
    
    </div>
    </body>
</html>